var http = require("http");
var fs = require("fs");

var DocUrl = "C:/Users/Administrator/Desktop/OnlineExercise"
http.createServer(function(req,res){
	console.log("有客户端连接");
	var url = req.url;
	var file = DocUrl+url;
	fs.readFile(file,function(err,data){
		if(err){
			res.writeHeader(404,{
				'content-type':'text/html;charset="utf-8"'
			});
			res.write('<h1>404错误</h1><p>你要找的页面不存在</p>');
			res.end();
		}else{
			res.writeHeader(200,{'content-type':'text/html'});
			res.write(data);
			res.end();
		}
	})
	
}).listen(8888);
console.log("http://localhost:8888");